home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 41
/
Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso
/
-seriously_amiga-
/
programming
/
other
/
gui4cli
/
ext
/
gcview
/
gcview.gc
< prev
next >
Wrap
Text File
|
1999-04-29
|
16KB
|
736 lines
G4C
; ******************** This is a Gui4Cli gui *********************
; - You need Gui4Cli version 3.7+ to run it
; - Get it from Aminet or <http://users.hol.gr/~dck/gcmain.htm>
; ****************************************************************
; TAB size is 3
; This gui works fine, but it is still a long way from finished.
; It does however, make gcview easier to use. Feel free to change it..
; ================================================================
WINBIG -1 -10 640 95 '' ; note -10 for top (see guide)
wintype 00001100
screen GCView
; resinfo 8 640 256
BOX 0 0 0 0 out button
xOnLoad
Local scheight/winheight/barheight
screentog = 0 ; screen2front toggle
loadedas = NORMAL
start = 0
frames = 60
file = ''
loadall = ON
andir = PINGPONG
dmode = BG
extract #this guipath mypath
palette = 0
setgad #this 20 hide ; palette lv
JoinFile $mypath Palettes PalPath
lvuse #this 20
lvdir #$PalPath
fcount = 0
savepath = T:
savebase = GCPic
savename = ''
makescreen GCView 3 'Gui4Cli Gui 4 GCView by dck@hol.gr'
; start gcview - should be in the same dir as us
ifexists port ~gcview
joinfile $mypath gcview gcvname
run $gcvname
wait port gcview 100
if $$retcode > 0
ezreq 'Could not launch GCView!\n' Abort ''
guiquit #this
endif
endif
; get our screen height
scheight = 256
barheight = 12
call gcview info pubscreen GCView
tempvar = $$call.ret
parsevar tempvar
if $$parse.total > 3
scheight = $$parse.3
barheight = $$parse.5
endif
; open window right below menu bar & get actual height
; changegad #this 0 -1 $barheight 0 95 '' ; doesn't work.. ?
guiopen #this
info gui #this
winheight = $$win.h
; move screen down..
scpos = $($scheight - $barheight - $winheight)
movescreen #this 0 $scpos ; new function
call gcview set pointer on
; set my palette, if available
ifexists file guis:tools/palette/gray
guiload guis:tools/palette/gray gcview.gc
endif
; notify keys
call gcview notify RMB Gui4Cli 'gosub gcview.gc do_rmb'
; call gcview notify R78 Gui4Cli 'gosub gcview.gc speed_inc'
; call gcview notify R79 Gui4Cli 'gosub gcview.gc speed_dec'
xOnQuit
guiclose #this
killscreen GCView
call gcview quit force
xOnRMB
gosub #this do_rmb
; -----------------------------------------------------------
; RMB routines
; -----------------------------------------------------------
xRoutine do_rmb
if $screentog = 0
guiscreen gcview.gc back
screentog = 1
else
guiscreen gcview.gc front
screentog = 0
endif
; xRoutine speed_inc
; call gcview set speed
; xRoutine speed_dec
; -----------------------------------------------------------
; crop & tile
; -----------------------------------------------------------
XICON 273 0 :icn/crop
gadhelp 'Crops the picture/anim to the size you have marked'
call gcview crop mypic
guiscreen gcview.gc front
; -----------------------------------------------------------
; Tile
; -----------------------------------------------------------
XICON 273 15 :icn/mtile
gosub #this tilepic 1
XICON 273 30 :icn/tile
gosub #this tilepic 0
xRoutine tilepic mirror ; if mirror=1 then do mirror tile
guiwindow #this wait
if $type = ANIM
if $mirror = 1
call gcview tile mypic MIRROR
else
call gcview tile mypic
endif
else
; if there is a box, get size and crop it..
call gcview info boxsize mypic
info = $$call.ret
parsevar info
if $$parse.2 > 0
call gcview crop mypic
endif
call gcview rename mypic brush
call gcview create mypic 640 512 8
call gcview open mypic
call gcview close brush
call gcview set palette mypic brush
if $mirror = 1
call gcview tile brush mypic MIRROR
else
call gcview tile brush mypic
endif
call gcview unload brush
endif
guiwindow #this resume
guiscreen gcview.gc front
; -----------------------------------------------------------
; 4 way mirror tile (for making bgnd patterns)
; -----------------------------------------------------------
XICON 273 45 :icn/mirror ; do 4 way mirror
local w/d/h/sw/sh
if $type = ANIM
flash ; not for anims..
stop
endif
; get sizes
call gcview info size mypic
size = $$call.ret
parsevar size
w = $$parse.0
h = $$parse.1
d = $$parse.2
sw == $w * 2
sh == $h * 2
; prepare background for tiling..
call gcview rename mypic brush
call gcview create mypic $sw $sh $d
call gcview open mypic
call gcview close brush
call gcview set palette mypic brush
; paste & flip & paste...
call gcview paste brush mypic 0 0
call gcview flip brush horizontal
call gcview paste brush mypic $w 0
call gcview flip brush vertical
call gcview paste brush mypic $w $h
call gcview flip brush horizontal
call gcview paste brush mypic 0 $h
; finished..
call gcview unload brush
guiscreen gcview.gc front
; -----------------------------------------------------------
; Flip and rotate buttons
; -----------------------------------------------------------
XICON 303 0 :icn/HFlip
call gcview flip mypic horizontal
XICON 303 15 :icn/VFlip
call gcview flip mypic vertical
XICON 303 30 :icn/RRotate
call gcview rotate mypic right
XICON 303 45 :icn/LRotate
call gcview rotate mypic left
; -----------------------------------------------------------
; PAN
; -----------------------------------------------------------
; ------------- Vertical
XICON 334 45 :icn/vpan
call gcview pan mypic MIRROR VERTICAL
XICON 333 30 :icn/vpanNoMirr
call gcview pan mypic VERTICAL
; ------------ Horizintal
XICON 333 0 :icn/panNoMirr
call gcview pan mypic
XICON 333 15 :icn/pan
call gcview pan mypic MIRROR
; -----------------------------------------------------------
; SAVE, QUIT...
; -----------------------------------------------------------
; ------------ normal save
XICON 605 4 :icn/save
local fname/fileline
if $file < ' '
file = T:GCPic
endif
; store the current line in lv, so we can go back to it
; after refreshing the lv
lvuse #this 1
fileline = $$lv.line
; try to be clever.. Use previously saved file's path
if $savename > ''
extract savename path savename
extract file file fname
joinfile $savename $fname fname
else
fname = $file
endif
savename = ''
call gcview move pubscreen GCView 0 15
ReqFile -1 -1 300 -40 'Save current picture:' SAVE savename #$fname
call gcview move pubscreen GCView 0 $scpos
if $savename > ''
ifexists file $savename
ezreq 'File already exists:\n- $savename\nOverwite ?' OverWrite|Cancel choice
if $choice = 0
stop ; user cancelled
endif
endif
guiwindow #this wait
call gcview save mypic '$savename'
guiwindow #this resume
; refresh the dir, and go to previously current line
lvdir refresh
lvmove #$fileline
lvgo #$fileline
lvmulti on
endif
; ------------ Clear & quit
XICON 605 19 :icn/clear
; unload all pics and anims (keep palettes)
call gcview unload #PIC
call gcview unload #ANIM
XICON 605 34 :icn/quit
local choice
ezreq 'Quit GCView ?' 'Quit|CANCEL' choice
if $choice = 1
guiquit #this
endif
; ------------ Open/Close WB
XICON 605 54 :icn/wbtog
ifexists screen 'Workbench'
workbench close
else
workbench open
endif
; -----------------------------------------------------------
; The listview
; -----------------------------------------------------------
XLISTVIEW 4 0 210 92 "" file "" 10 DIR
gadid 1
gadfont #mono 8 000
attr lvfilter "~(#?.info)" ; set filter - no icons
gosub #this showfile
guiscreen gcview.gc front
lvmulti none
lvmove #$$lv.line
lvmulti on
xRoutine showfile ; show $file - also used from view icon
gosub gcview.gc gettype
if $type != NONE
and $type != ANIM
if $dmode = BG ; normal background
call gcview rename mypic oldpic
call gcview load $file mypic
if $$retcode > 0 ; no memory..
call gcview unload oldpic
call gcview load $file mypic
call gcview open mypic
else
call gcview open mypic
call gcview unload oldpic
endif
if $usepalette = ON
call gcview set palette mypic mypal
endif
bgdir = $$lv.dir
gosub #this showinfo
else ; paste brush mode
gosub GCVIEW.GC pastebrush
endif
elseif $type = ANIM
if $dmode = BG
bgdir = $$lv.dir
gosub #this playanim 0 ; 0=load as many frames as posible
if $usepalette = ON
call gcview set palette mypic mypal
endif
gosub #this showinfo
else ; paste anims onto each other
gosub GCVIEW.GC pastebrush
endif
else
; use default gui to handle file
guiload guis:tools/rtn/filepop $file
gosub #this showinfo
endif
xLVDirHook 1
lvuse #this 1
setscreentitle #this '$$lv.dir'
; -----------------------------------------------------------
; routine to paste brush into edit box
; -----------------------------------------------------------
xroutine pastebrush
if $file H= 'FORM????ANIM' ; ANIM
call gcview anload $file brush 0 1000 FORWARD
else
call gcview load $file brush
endif
; store dir
extract file path brushdir
; get edit box size
call gcview info boxsize mypic
info = $$call.ret
parsevar info
x = $$parse.0
y = $$parse.1
w = $$parse.2
h = $$parse.3
if $w <= 0 ; no box
ezreq 'Please draw Edit Box first\nby click-dragging mouse.\nBrush will be sized and\npositioned accordingly' OK ''
stop
endif
; adjust & paste brush
call gcview resize brush $w $h
call gcview paste brush mypic $x $y
call gcview unload brush
guiscreen gcview.gc front
; -----------------------------------------------------------
; routine to get picture file types
; -----------------------------------------------------------
xRoutine gettype
readvar $file 0 16 header ; read the header
set deeptrans off
; add here any other formats you have datatypes for
type = NONE
docase $header
case S= 'FORM????ILBM' ; IFF
case S= "??????JFIF" ; JPEG
case S= "ÿØÿÄ" ; JPEG
case S= "GIF" ; GIF
case S= "?PNG" ; PNG
type = PIC
break
case S= 'FORM????ANIM' ; ANIM
type = ANIM
endcase
set deeptrans on
; -----------------------------------------------------------
; View selected files
; -----------------------------------------------------------
XICON 240 0 ":icn/View"
StopView = 0 ; flag to abort viewing
; install notify command
call gcview notify V32 Gui4Cli 'gosub gcview.gc ViewNext'
call gcview notify V13 Gui4Cli 'gosub gcview.gc ViewNext'
lvuse #this 1
lvmulti first
gosub #this ViewRtn
xRoutine ViewNext
lvuse #this 1
lvmulti off
lvmulti next
gosub #this ViewRtn
xRoutine ViewRtn ; actually show the file, or stop
if $$lv.line > ''
and $StopView = 0
gosub #this showfile ; same routine as the LV itself
else
call gcview unload #PIC
call gcview unload #ANIM
call gcview delnotify V13
call gcview delnotify V32
guiscreen gcview.gc front
stop
endif
; -----------------------------------------------------------
; Delete file
; -----------------------------------------------------------
XICON 240 15 ":icn/Delete"
lvuse #this 1
lvaction delete REQ
; -----------------------------------------------------------
; listview controls
; -----------------------------------------------------------
XBUTTON 216 0 20 15 "P"
lvuse #this 1
lvdir parent
setscreentitle #this '$$lv.dir'
XBUTTON 216 15 20 15 "D"
lvuse #this 1
lvdir disks
setscreentitle #this Devices
XBUTTON 216 30 20 15 "A"
lvuse #this 1
lvmulti all
XBUTTON 216 45 20 15 "N"
lvuse #this 1
lvmulti none
XBUTTON 216 60 20 15 "<"
lvuse #this 1
lvmove -1000
XBUTTON 216 75 20 15 "R"
lvuse #this 1
lvdir refresh
; ---------------------------------------------------------
; status box
; ---------------------------------------------------------
TEXT 370 2 225 14 "" 100 BOX
gadid 10
; -----------------------------------------------------------
; anims
; -----------------------------------------------------------
;* BOX 309 17 231 52 in button
XCHECKBOX 444 42 30 15 "LoadAll" loadall "ON" "OFF" ON
gadid 2
if $loadall == ON
setgad #this 3/4 on
else
setgad #this 3/4 off
endif
XHSLIDER 422 18 146 11 "Start" start 0 100 0 "%ld"
gadid 3
gosub #this checklength
XHSLIDER 422 29 146 11 "Long" frames 0 60 60 "%ld"
gadid 4
gosub #this checklength
xroutine checklength
remain = $($frtotal - $start)
if $frames > $remain
frames = $remain
update #this 4 $frames
endif
XICON 475 42 :icn/Backward
if $loadedas = LOADALL
call gcview set direction mypic backward
endif
andir = BACKWARD
XICON 505 42 :icn/forward
call gcview set direction mypic forward
andir = FORWARD
XICON 536 42 :icn/pingpong
if $loadedas = LOADALL
call gcview set direction mypic ping
endif
andir = PINGPONG
XICON 474 57 ":icn/AddFrame" ; add a frame
call gcview addframe mypic
gosub #this showinfo
; guiscreen #this front
; guiscreen gcview.gc front
XICON 505 57 ":icn/DelFrame<" ; delete frame from end
call gcview info anim mypic
info = $$call.ret
parsevar info
if $$parse.tot > 1
call gcview delframe mypic $($$parse.1 - 1) 1
endif
gosub #this showinfo
XICON 535 57 ":icn/DelFrame>" ; delete frame from start
call gcview delframe mypic 0 1
gosub #this showinfo
XICON 444 57 :icn/RRotate ; reload with new settings
if $file > ''
gosub #this playanim 1
gosub #this showinfo
endif
xRoutine playanim userange ; play anim - if userange=1, use the
call gcview unload mypic ; start/frame values as set
if $loadall == ON
loadedas = LOADALL
if $userange = 1
call gcview anload $file mypic $start $frames $andir
else
call gcview anload $file mypic 0 1000 $andir
endif
else
loadedas = NORMAL
call gcview load $file mypic
endif
call gcview open mypic
guiscreen gcview.gc front
; -----------------------------------------------------------
; update info display
; -----------------------------------------------------------
xroutine showinfo
local info
extract file file name
if $type = ANIM
call gcview info anim mypic
info = $$call.ret
parsevar info
frtotal = $$parse.0
frstart = $$parse.1
frloaded = $$parse.2
if $frloaded > 0
update #this 10 '$name ($frtotal\f) LOADED:$frloaded'
else
update #this 10 '$name : $frtotal'
endif
start = $frstart
frames = $frloaded
changearg #this 3 7 $frtotal
changearg #this 4 7 $frtotal
update #this 3 $frstart
update #this 4 $frloaded
redraw #this
; use sizes from box
; partredraw #this 309 18 234 46
else
update #this 10 '$type : $name'
endif
; -----------------------------------------------------------
; add brushes
; -----------------------------------------------------------
XCYCLER 237 75 116 15 "" dmode
CSTR "Bgnd" BG
CSTR 'Brush' BR
lvuse #this 1
if $dmode = BG
lvdir #$bgdir
else
lvdir #$brushdir
endif
; -----------------------------------------------------------
; use palette
; -----------------------------------------------------------
XICON 303 60 :icn/palette
call gcview move pubscreen GCView 0 0
ReqFile -1 -1 300 -40 'Choose a palette' LOAD palname ''
call gcview move pubscreen GCView 0 160
ifexists file $palname
call gcview unload mypal
call gcview load $palname mypal
endif
XCHECKBOX 333 60 20 15 "" usepalette "ON" "" OFF
gadid 9
ifexists file ~$palname
ezreq 'Please choose a palette!\n' "OK" ""
update #this 9 0
endif
; -----------------------------------------------------------
; zoom to screen
; - if there is an edit box, zoom the contents
; - otherwise fit the picture to the screen
; -----------------------------------------------------------
XICON 273 60 :icn/Zoom
local x/y/w/h
; get edit box size
call gcview info boxsize mypic
info = $$call.ret
parsevar info
x = $$parse.0
y = $$parse.1
w = $$parse.2
h = $$parse.3
if $w <= 0 ; no box - zoom the whole picture
call gcview info size mypic
size = $$call.ret
parsevar size
w = $$parse.0
h = $$parse.1
x = 0
y = 0
endif
guiwindow #this wait
call gcview zoom mypic $x $y $w $h
guiwindow #this resume
guiscreen gcview.gc front
; -----------------------------------------------------------
; Palette presets handling
; - make a list of available palettes & browse through them
; -----------------------------------------------------------
XLISTVIEW 2 0 210 92 "" palfile '' 10 DIR
gadid 20
XICON 605 69 :icn/nextpal
lvuse #this 20
lvmulti none
lvgo #$palette
if $$lv.line = ''
palette = 0
lvgo #0
endif
lvmulti on
lvmulti first
guiload $palfile gcview.gc
++palette